{% extends "base.html" %}

{% block title %}侦察员工作台 - 协同调度信息系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0">
                    <i class="fas fa-search"></i> 侦察员工作台
                </h4>
            </div>
            <div class="card-body">
                <div class="row mb-4">
                    <div class="col-md-6">
                        <div class="d-grid">
                            <a href="{{ url_for('add_recon_data') }}" class="btn btn-primary">
                                <i class="fas fa-plus"></i> 提交新的侦察数据
                            </a>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="alert alert-info mb-0">
                            <i class="fas fa-info-circle"></i>
                            <strong>当前状态:</strong> 已提交 {{ recon_data|length }} 条侦察数据
                        </div>
                    </div>
                </div>

                {% if recon_data %}
                <h5><i class="fas fa-list"></i> 我的侦察数据</h5>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead class="table-dark">
                            <tr>
                                <th>标题</th>
                                <th>目标系统</th>
                                <th>数据类型</th>
                                <th>优先级</th>
                                <th>状态</th>
                                <th>提交时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for data in recon_data %}
                            <tr>
                                <td>
                                    <strong>{{ data.title }}</strong>
                                </td>
                                <td>{{ data.target_system }}</td>
                                <td>
                                    <span class="badge bg-info">
                                        {% if data.data_type == 'network' %}网络信息
                                        {% elif data.data_type == 'system' %}系统信息
                                        {% elif data.data_type == 'vulnerability' %}漏洞信息
                                        {% elif data.data_type == 'user' %}用户信息
                                        {% elif data.data_type == 'service' %}服务信息
                                        {% else %}其他
                                        {% endif %}
                                    </span>
                                </td>
                                <td>
                                    <span class="priority-badge priority-{{ data.priority }}">
                                        {% if data.priority == 'low' %}低
                                        {% elif data.priority == 'medium' %}中
                                        {% elif data.priority == 'high' %}高
                                        {% elif data.priority == 'critical' %}紧急
                                        {% endif %}
                                    </span>
                                </td>
                                <td>
                                    <span class="status-badge status-{{ data.status }}">
                                        {% if data.status == 'pending' %}待分析
                                        {% elif data.status == 'analyzed' %}已分析
                                        {% elif data.status == 'processed' %}已处理
                                        {% endif %}
                                    </span>
                                </td>
                                <td>{{ data.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                                <td>
                                    <button class="btn btn-sm btn-outline-primary" 
                                            data-bs-toggle="modal" 
                                            data-bs-target="#viewModal{{ data.id }}">
                                        <i class="fas fa-eye"></i> 查看
                                    </button>
                                </td>
                            </tr>
                            
                            <!-- 查看详情模态框 -->
                            <div class="modal fade" id="viewModal{{ data.id }}" tabindex="-1">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title">{{ data.title }}</h5>
                                            <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                        </div>
                                        <div class="modal-body">
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <p><strong>目标系统:</strong> {{ data.target_system }}</p>
                                                    <p><strong>数据类型:</strong> 
                                                        {% if data.data_type == 'network' %}网络信息
                                                        {% elif data.data_type == 'system' %}系统信息
                                                        {% elif data.data_type == 'vulnerability' %}漏洞信息
                                                        {% elif data.data_type == 'user' %}用户信息
                                                        {% elif data.data_type == 'service' %}服务信息
                                                        {% else %}其他
                                                        {% endif %}
                                                    </p>
                                                </div>
                                                <div class="col-md-6">
                                                    <p><strong>优先级:</strong> 
                                                        <span class="priority-badge priority-{{ data.priority }}">
                                                            {% if data.priority == 'low' %}低
                                                            {% elif data.priority == 'medium' %}中
                                                            {% elif data.priority == 'high' %}高
                                                            {% elif data.priority == 'critical' %}紧急
                                                            {% endif %}
                                                        </span>
                                                    </p>
                                                    <p><strong>状态:</strong> 
                                                        <span class="status-badge status-{{ data.status }}">
                                                            {% if data.status == 'pending' %}待分析
                                                            {% elif data.status == 'analyzed' %}已分析
                                                            {% elif data.status == 'processed' %}已处理
                                                            {% endif %}
                                                        </span>
                                                    </p>
                                                </div>
                                            </div>
                                            <hr>
                                            <h6>侦察内容:</h6>
                                            <div class="bg-light p-3 rounded">
                                                <pre style="white-space: pre-wrap; margin: 0;">{{ data.content }}</pre>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% else %}
                <div class="text-center py-5">
                    <i class="fas fa-search fa-3x text-muted mb-3"></i>
                    <h5 class="text-muted">暂无侦察数据</h5>
                    <p class="text-muted">点击上方按钮提交您的第一条侦察数据</p>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}
